package com.foton.orderserver;

import com.foton.bpc.all.config.annotion.EnableBpc;
import com.foton.orderserver.order.OrderSmsImpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.*;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

@PropertySources(@PropertySource(value = "classpath:trpc.properties", ignoreResourceNotFound = true, encoding = "UTF-8"))
@SpringBootApplication
@EnableBpc
public class OrderServerApplication {

    public static void main(String[] args) {
       // SpringApplication.run(OrderServerApplication.class, args);

        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(OrderServerApplication.class);
        applicationContext.start();

//        final CyclicBarrier cyclicBarrier=new CyclicBarrier(10);
//
        for (int i = 0; i <10 ; i++) {
            new Thread(()->{
                try {
//                    cyclicBarrier.await();
                    OrderSmsImpl orderSms = applicationContext.getBean(OrderSmsImpl.class);
                    orderSms.create("买一部iPhone15ProMax");

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }).start();
        }



    }

}
